using UnityEngine;

namespace Gj
{
    public class CoverService : GameService
    {
        public static CoverService single;

        static CoverService()
        {
            single = new CoverService();
        }

        public void OnDestroy()
        {
        }

        public void OnInit()
        {
        }

        public void OnUpdate()
        {
            
        }

        public GameObject MakeCover(string name, Vector3 position, float angle, float size)
        {
            var obj = ObjectService.single.MakeCover(name.Substring(0, 1).ToUpper() + name.Substring(1));
            if (obj == null) return null;
            obj.transform.SetPositionAndRotation(position, Quaternion.Euler(new Vector3(0, angle, 0)));
            obj.transform.localScale = new Vector3(size, size, size);
            obj.SetActive(true);
            return obj;
        }

        public void DestroyCover(GameObject obj)
        {
            obj.SetActive(false);
            ObjectService.single.DestroyObj(obj);
        }
    }
}